# -*- coding:utf-8 -*-
#2022/1/18 14:35
# author:xwl
from fastapi import APIRouter, Depends

from backend.app.app.api.api_Xiong.crud.pri_crud import save_data_well_caldata, save_data_well_data, read_well_input, \
    read_well_output, read_data_well_data
from backend.app.app.api.api_Xiong.models.x_model import input_data_recovery_save
from backend.app.app.api.api_v1.user import verify_token_user

input_data_recovery = APIRouter(prefix="/input_data_recovery", tags=["输入数据-数据恢复"])

@input_data_recovery.post("/save",name="存储")
def save(data:input_data_recovery_save, ver=Depends(verify_token_user)):
    well_caldata_result=save_data_well_caldata(data.User_ID, data.Proj_ID,data.Data)
    save_input_success,save_output_success=save_data_well_data(data.User_ID, data.Proj_ID,data.Inputdata, data.Outputdata)
    return {
        'well_caldata_result':well_caldata_result,
        'save_input_result':save_input_success,
        'save_output_result':save_output_success,
        'verify': ver
    }

@input_data_recovery.post("/return_data",name="返回")
def return_data(User_ID,Proj_ID, ver=Depends(verify_token_user)):
    input_result=read_well_input(User_ID,Proj_ID)
    output_result=read_well_output(User_ID,Proj_ID)
    data=read_data_well_data(User_ID,Proj_ID)
    return {
        'input_result':input_result,
        'output_result':output_result,
        'Data':data,
        'verify': ver
    }
